# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

import coin.exchange.base.kr_rest.native_public_client_base as npubcb
import coin.exchange.hitbtc_v2.kr_rest.constants as exchange_constants


class HitbtcNativePublicClient(npubcb.NativePublicClientBase):
  def __init__(self, timeout=1):
    npubcb.NativePublicClientBase.__init__(self,
                                           url="https://api.hitbtc.com/api/2/public",
                                           timeout=timeout)

  def get_currencies(self, currency=None):
    currency = currency or ''
    url = 'currency/%s' % currency
    update = self._get_as_json(url)
    return update

  def get_symbols(self, symbol=None):
    symbol = symbol or ''
    url = "symbol/%s" % symbol
    update = self._get_as_json(url)
    return update

  def get_tickers(self, symbol=None):
    symbol = symbol or ''
    url = "ticker/%s" % symbol
    update = self._get_as_json(url)
    return update

  def get_trades(self, symbol):
    url = "trades/%s" % symbol
    update = self._get_as_json(url)
    return update

  def get_orderbook(self, symbol):
    url = "orderbook/%s" % symbol
    update = self._get_as_json(url)
    return update

  def get_candles(self, symbol):
    url = "candles/%s" % symbol
    update = self._get_as_json(url)
    return update

  def queryAll(self):
    for symbol in exchange_constants.symbol_list[:2]:
      print(self.get_orderbook(symbol))


if __name__ == "__main__":
  client = HitbtcNativePublicClient(timeout=10)
  print(client.get_symbols())
  print(client.get_currencies())
  client.queryAll()
